package com.huazi.www.drug.drugy.service.impl;


import com.huazi.www.drug.drugy.dao.DoctorDao;
import com.huazi.www.drug.drugy.dao.impl.DoctorDaoImpl;
import com.huazi.www.drug.drugy.entity.Doctor_information;
import com.huazi.www.drug.drugy.service.DoctorService;
import com.huazi.www.drug.drugy.util.Page;

/**
 * @author 波——最帅的男人
 * @version 1.0
 * @date 2021/5/13 16:11
 */
public class DoctorServiceImpl implements DoctorService {
    DoctorDao dao = new DoctorDaoImpl();

    /**
     * 分布查询医生
     *
     * @param currentPage
     * @param name
     * @return
     */
    @Override
    public Page<Doctor_information> pageList2(Integer currentPage, String name) {
        Page<Doctor_information> page = new Page<>();
        page.setCurrentPage(currentPage);
        page.setPageSize(4);
        page.setTotalCount(dao.selectDoctorCount(name));
        page.setList(dao.selectDoctor(name, (currentPage - 1) * page.getPageSize(), page.getPageSize()));
        return page;
    }

    /**
     * 医生插入
     *
     * @param doctor_information
     * @return
     */
    @Override
    public boolean insertDoctor(Doctor_information doctor_information) {
        int i = dao.insertDoctor(doctor_information);
        if (i == 1) {
            return true;
        }
        return false;
    }

    /**
     * 医生删除
     *
     * @param id
     * @return
     */
    @Override
    public boolean deleteDoctor(Integer id) {
        int i = dao.deleteDoctor(id);
        if (i == 1) {
            return true;
        }
        return false;
    }

    /**
     * 更新医生信息
     *
     * @param doctor_information
     * @return
     */
    @Override
    public boolean updateDoctor(Doctor_information doctor_information) {
        int count = dao.updateDoctor(doctor_information);
        if (count == 1) {
            return true;
        }
        return false;
    }
}
